﻿#pragma strict

static var activerGauche:boolean;
static var activerDroite:boolean;
static var numeroMenu=1;
private var deplacement:int;
public var fond: SpriteRenderer;
public var fondG:Sprite;
public var fondD:Sprite;

function Start () {
	activerDroite=false;
	activerGauche=false;
	deplacement=0;
	this.transform.GetChild(1).position.x=this.transform.GetChild(0).position.x+this.transform.parent.GetComponent(SpriteRenderer).sprite.bounds.size.x*this.transform.parent.localScale.x;
}

function Update () {

	if(activerDroite)
	{
		this.transform.position.x-=2;
		deplacement+=2;
		if(deplacement>=this.transform.parent.GetComponent(SpriteRenderer).sprite.bounds.size.x*this.transform.parent.localScale.x)
		{
			deplacement=0;
			activerDroite=false;
			fond.sprite=fondD;
		}
	}
	else if(activerGauche)
	{
		this.transform.position.x+=2;
		deplacement+=2;
		if(deplacement>=this.transform.parent.GetComponent(SpriteRenderer).sprite.bounds.size.x*this.transform.parent.localScale.x)
		{
			deplacement=0;
			activerGauche=false;
			fond.sprite=fondG;
		}
	}

}